/*
 * Copyright (c) 2018-2999 深圳市阿毛科技有限公司 All rights reserved.
 *
 * https://www.lamyz.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.lam.mall.api.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lam.common.base.domain.Result;
import com.lam.framework.operLog.annotation.Log;
import com.lam.mall.app.vo.CategoryVo;
import com.lam.mall.entity.Category;
import com.lam.mall.param.CategoryParam;
import com.lam.mall.service.CategoryService;

import cn.hutool.core.bean.BeanUtil;

/**
 */
@Log(title = "商品分类")
@RestController
@RequestMapping("/${frontPath}/category")
public class CategoryApiController {

    @Autowired
    private CategoryService categoryService;


    /**
     * 分类信息列表接口
     * 获取所有的产品分类信息，顶级分类的parentId为0,默认为顶级分类
     */
    @GetMapping("/categoryInfo")
    @Log(oper = "分类信息列表")
    public Result categoryInfo(@RequestParam(value = "parentId", defaultValue = "0") String parentId) {
    	
        CategoryParam param = new CategoryParam();
        param.setParentId(parentId);
		List<Category> categories = categoryService.selectList(param );
        return Result.ok(BeanUtil.copyToList(categories, CategoryVo.class));
    }


}
